package Merlion.util.state;

import Merlion.CRM.entity.ClientEntity;
import Merlion.CRM.entity.LineEntryEntity;
import Merlion.CRM.entity.PurchaseOrderEntity;
import Merlion.CRM.entity.QuotationEntity;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

public class SalesDocumentState implements Serializable {

    private Long id;
    private Date dateIssued;
    private String deleteFlag = "N";//"Y"/"N"
    private String documentType;//"SI/QN/PO/SO"
    private ClientEntity client;
    private String clientName;
    private Long clientId;
    private String contactName;
    private Long contactId;
    private Collection<LineEntryEntity> lineEntryList;
    private String status;
    private Date date;
    private Date validUntil;
    private int indicativeLeadTime;
    private QuotationEntity quotation;
    private Long    quotationID;
    private String ATPCheckStatus;
    private String creditCheckStatus;
    private PurchaseOrderEntity purchaseOrder;
    private Long poID;
    private double totalPrice;
    private String description;
    private String pricingType;
    private boolean referred;
    private boolean approved; //approved by customer
    private boolean packed;
    private boolean shipped;
    private boolean rejected;
    private boolean onHold;
    private boolean validated;
    private boolean voided;
    private boolean completed;
    private boolean cashInAdvanced;

  
    //for primary billing address
    private Long billingId;
    private String billingStreet = "";
    private String billingState = "";
    private String billingCity = "";
    private String billingCode = "";
    private String billingCountry = "";
    
    //for primary shipping address;
    private Long shippingId;
    private String shippingStreet = "";
    private String shippingState = "";
    private String shippingCity = "";
    private String shippingCode = "";
    private String shippingCountry = "";
    private int leadTime;//for sales order
    private int confirmedLeadTime;//for sales order
    
    //for sales order and purchase order
    private String documentName;
    private String shippingMethod;
    private String shippingRule;
    private String invoiceRule;
    private String paymentMethod;
    private String freightCostRule;
    private String currency;
    private Date dueDate;
    private String priority;//for sales order only

    public SalesDocumentState() {
    }

    public SalesDocumentState(Long id, Date dateIssued, ClientEntity client, String status) {

        this.setId(id);
        this.setDateIssued(dateIssued);
        this.setClient(client);
        this.setStatus(status);
    }

    //for Quotation
    public SalesDocumentState(Long id, Date dateIssued, Date validUntil, int indicativeLeadTime,
            Long clientId, String clientName,
            Collection<LineEntryEntity> lineEntryList) {

        this.setId(id);
        this.setDateIssued(dateIssued);
        this.setValidUntil(validUntil);
        this.setIndicativeLeadTime(indicativeLeadTime);
        this.setClientId(clientId);
        this.setClientName(clientName);

        this.setLineEntryList(lineEntryList);
    }

    //for Sales Inquiry
    public SalesDocumentState(Long id, Date dateIssued, Long clientId, String clientName, String status,
            Collection<LineEntryEntity> lineEntryList) {

        this.setId(id);
        this.setDateIssued(dateIssued);
        this.setClientId(clientId);
        this.setClientName(clientName);
        this.setStatus(status);
        this.setLineEntryList(lineEntryList);
        // this.setTotalPrice(totalPrice);
    }

    //for Purchase Order
    public SalesDocumentState(Long id, Date dateIssued, Long clientId, String clientName, String status,
            Collection<LineEntryEntity> lineEntryList, QuotationEntity quotation, Long quotationID) {

        this.setId(id);
        this.setDateIssued(dateIssued);
        this.setClientId(clientId);
        this.setClientName(clientName);
        this.setStatus(status);
        this.setLineEntryList(lineEntryList);
        this.setQuotation(quotation);
        this.setQuotationID(quotationID);
    }

    //for Sales Order
    public SalesDocumentState(Long id, Date dateIssued, Long clientId, String clientName, String status, String ATPCheckStatus,
            String creditCheckStatus, Collection<LineEntryEntity> lineEntryList, PurchaseOrderEntity purchaseOrder,
            Long poID) {

        this.setId(id);
        this.setDateIssued(dateIssued);
        this.setClientId(clientId);
        this.setClientName(clientName);
        this.setStatus(status);
        this.setLineEntryList(lineEntryList);
        this.setATPCheckStatus(ATPCheckStatus);
        this.setCreditCheckStatus(creditCheckStatus);
        this.setPurchaseOrder(purchaseOrder);
        this.setPoID(poID);
    }

    public Long getContactId() {
        return contactId;
    }

    public void setContactId(Long contactId) {
        this.contactId = contactId;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public int getLeadTime() {
        return leadTime;
    }

    public void setLeadTime(int leadTime) {
        this.leadTime = leadTime;
    }

    public String getPricingType() {
        return pricingType;
    }

    public void setPricingType(String pricingType) {
        this.pricingType = pricingType;
    }

    public boolean isReferred() {
        return referred;
    }

    public void setReferred(boolean referred) {
        this.referred = referred;
    }

    public boolean isApproved() {
        return approved;
    }

    public void setApproved(boolean approved) {
        this.approved = approved;
    }

    public boolean isCashInAdvanced() {
        return cashInAdvanced;
    }

    public void setCashInAdvanced(boolean cashInAdvanced) {
        this.cashInAdvanced = cashInAdvanced;
    }

    public boolean isCompleted() {
        return completed;
    }

    public void setCompleted(boolean completed) {
        this.completed = completed;
    }

    public boolean isOnHold() {
        return onHold;
    }

    public void setOnHold(boolean onHold) {
        this.onHold = onHold;
    }

    public boolean isPacked() {
        return packed;
    }

    public void setPacked(boolean packed) {
        this.packed = packed;
    }

    public boolean isRejected() {
        return rejected;
    }

    public void setRejected(boolean rejected) {
        this.rejected = rejected;
    }

    public boolean isShipped() {
        return shipped;
    }

    public void setShipped(boolean shipped) {
        this.shipped = shipped;
    }

    public boolean isValidated() {
        return validated;
    }

    public void setValidated(boolean validated) {
        this.validated = validated;
    }

    public boolean isVoided() {
        return voided;
    }

    public void setVoided(boolean voided) {
        this.voided = voided;
    }
    
 
    
    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public String getDescription() {

        return description;
    }

    public void setDescription(String description) {
        if (description != null) {
            if (description.equals("")) {
                description = "No description found.";
            }
        } else if (description == null) {
            description = "No description found.";
        }
        this.description = description;
    }

    public Long getPoID() {
        return poID;
    }

    public void setPoID(Long poID) {
        this.poID = poID;
    }

    public PurchaseOrderEntity getPurchaseOrder() {
        return purchaseOrder;
    }

    public void setPurchaseOrder(PurchaseOrderEntity purchaseOrder) {
        this.purchaseOrder = purchaseOrder;
    }

    public Long getBillingId() {
        return billingId;
    }

    public void setBillingId(Long billingId) {
        this.billingId = billingId;
    }

    public Long getShippingId() {
        return shippingId;
    }

    public void setShippingId(Long shippingId) {
        this.shippingId = shippingId;
    }

    public Long getQuotationID() {
        return quotationID;
    }

    public void setQuotationID(Long quotationID) {
        this.quotationID = quotationID;
    }

    public String getATPCheckStatus() {
        return ATPCheckStatus;
    }

    public void setATPCheckStatus(String ATPCheckStatus) {
        this.ATPCheckStatus = ATPCheckStatus;
    }

    public String getCreditCheckStatus() {
        return creditCheckStatus;
    }

    public void setCreditCheckStatus(String creditCheckStatus) {
        this.creditCheckStatus = creditCheckStatus;
    }

    public int getConfirmedLeadTime() {
        return confirmedLeadTime;
    }

    public void setConfirmedLeadTime(int confirmedLeadTime) {
        this.confirmedLeadTime = confirmedLeadTime;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public QuotationEntity getQuotation() {
        return quotation;
    }

    public void setQuotation(QuotationEntity quotation) {
        this.quotation = quotation;
    }

    public int getIndicativeLeadTime() {
        return indicativeLeadTime;
    }

    public void setIndicativeLeadTime(int indicativeLeadTime) {
        this.indicativeLeadTime = indicativeLeadTime;
    }

    public Date getValidUntil() {
        return validUntil;
    }

    public void setValidUntil(Date validUntil) {
        this.validUntil = validUntil;
    }

    public ClientEntity getClient() {
        return client;
    }

    public void setClient(ClientEntity client) {
        this.client = client;
    }

    public Long getClientId() {
        return clientId;
    }

    public void setClientId(Long clientId) {
        this.clientId = clientId;
    }

    public String getClientName() {
        return clientName;
    }

    public void setClientName(String clientName) {
        this.clientName = clientName;
    }

    public Date getDateIssued() {
        return dateIssued;
    }

    public void setDateIssued(Date dateIssued) {
        this.dateIssued = dateIssued;
    }

    public String getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(String deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public String getDocumentType() {
        return documentType;
    }

    public void setDocumentType(String documentType) {
        this.documentType = documentType;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Collection<LineEntryEntity> getLineEntryList() {
        lineEntryList.size();
        return lineEntryList;
    }

    public void setLineEntryList(Collection<LineEntryEntity> lineEntryList) {
        this.lineEntryList = lineEntryList;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        if (currency == null) {
            currency = "SGD";
        }
        this.currency = currency;
    }

    public String getDocumentName() {
        return documentName;
    }

    public void setDocumentName(String documentName) {

        if (documentName.equals("")) {
            documentName = "New Sales Document";
        }
        this.documentName = documentName;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public String getFreightCostRule() {
        return freightCostRule;
    }

    public void setFreightCostRule(String freightCostRule) {
        if (freightCostRule == null) {
            freightCostRule = "Freight Cost included.";
        }
        this.freightCostRule = freightCostRule;
    }

    public String getInvoiceRule() {
        return invoiceRule;
    }

    public void setInvoiceRule(String invoiceRule) {
        if (invoiceRule.equals("")) {
            invoiceRule = "After Delivery";
        }
        this.invoiceRule = invoiceRule;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        if (paymentMethod.equals("")) {
            paymentMethod = "On Credit";
        }
        this.paymentMethod = paymentMethod;
    }

    public String getPriority() {
        return priority;
    }

    public void setPriority(String priority) {
        if (priority == null) {
            priority = "Medium";
        }
        this.priority = priority;
    }

    public String getShippingMethod() {
        return shippingMethod;
    }

    public void setShippingMethod(String shippingMethod) {
        if (shippingMethod.equals("")) {
            shippingMethod = "Land";
        }
        this.shippingMethod = shippingMethod;
    }

    public String getShippingRule() {
        return shippingRule;
    }

    public void setShippingRule(String shippingRule) {
        if (shippingRule.equals("")) {
            shippingRule = "Availability";
        }
        this.shippingRule = shippingRule;
    }

    public String getBillingCity() {
        return billingCity;
    }

    public void setBillingCity(String billingCity) {
        if (billingCity.equals("")) {
            billingCity = " ";
        }
        this.billingCity = billingCity;
    }

    public String getBillingCode() {
        return billingCode;
    }

    public void setBillingCode(String billingCode) {
        if (billingCode.equals("")) {
            billingCode = " ";
        }
        this.billingCode = billingCode;
    }

    public String getBillingCountry() {
        return billingCountry;
    }

    public void setBillingCountry(String billingCountry) {
        if (billingCountry.equals("")) {
            billingCountry = " ";
        }
        this.billingCountry = billingCountry;
    }

    public String getBillingState() {
        return billingState;
    }

    public void setBillingState(String billingState) {
        if (billingState.equals("")) {
            billingState = " ";
        }
        this.billingState = billingState;
    }

    public String getBillingStreet() {
        return billingStreet;
    }

    public void setBillingStreet(String billingStreet) {
        if (billingStreet.equals("")) {
            billingStreet = " ";
        }
        this.billingStreet = billingStreet;
    }

    public String getShippingCity() {
        return shippingCity;
    }

    public void setShippingCity(String shippingCity) {
        if (shippingCity.equals("")) {
            shippingCity = " ";
        }
        this.shippingCity = shippingCity;
    }

    public String getShippingCode() {
        return shippingCode;
    }

    public void setShippingCode(String shippingCode) {
        if (shippingCode.equals("")) {
            shippingCode = " ";
        }
        this.shippingCode = shippingCode;
    }

    public String getShippingCountry() {
        return shippingCountry;
    }

    public void setShippingCountry(String shippingCountry) {
        if (shippingCountry.equals("")) {
            shippingCountry = " ";
        }
        this.shippingCountry = shippingCountry;
    }

    public String getShippingState() {
        return shippingState;
    }

    public void setShippingState(String shippingState) {
        if (shippingState.equals("")) {
            shippingState = " ";
        }
        this.shippingState = shippingState;
    }

    public String getShippingStreet() {
        return shippingStreet;
    }

    public void setShippingStreet(String shippingStreet) {
        if (shippingStreet.equals("")) {
            shippingStreet = " ";
        }
        this.shippingStreet = shippingStreet;
    }
}
